package com.luocj.muke.demo.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Paint;
import android.util.AttributeSet;

import com.luocj.muke.demo.R;


public class RoundProgressBar extends CustomProgressNumber {

    private int radius = dp2px(30);
    private int mMaxPaintWidth ;
    public RoundProgressBar(Context context) {
        super(context,null);
    }

    public RoundProgressBar(Context context, AttributeSet attrs) {
        super(context, attrs,0);
    }

    public RoundProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mReachHeight = (int) (mUnReachHeight  * 2.5f);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.RoundProgressBar);

        radius = (int) ta.getDimension(R.styleable.RoundProgressBar_radius,radius);

        ta.recycle();

        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
    }

    @Override
    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        mMaxPaintWidth = Math.max(mReachHeight,mUnReachHeight);

        int expect = radius * 2 + mMaxPaintWidth + getPaddingRight() +getPaddingLeft();

    }
}
